package com.spirng.leetcode.day09;

public class Test376 {
    public static void main(String[] args) {
        Test376 test376 = new Test376();
        int i = test376.wiggleMaxLength(new int[]{1, 7, 7, 4, 9, 2, 5});
    }
    public int wiggleMaxLength(int[] nums) {
        int res=1;
        int size=1;
        if(nums.length<=1){
            return 1;
        }
        int  perDiff=0;
        int curDiff;
        int count=1;
        for (int i = 1; i < nums.length; i++) {
            curDiff=nums[i]-nums[i-1];
            if(curDiff<0&&perDiff>=0||perDiff<=0&&curDiff>0){
                count++;
                perDiff=curDiff;
            }
        }
        return count++;
    }
}
